package cn.edu.java.io.writer;

import java.io.FileWriter;
import java.io.PrintWriter;
import java.io.IOException;

public class PrintWriterDemo {
    public static void main(String[] args) {
        try (PrintWriter printWriter = new PrintWriter(System.out)) {

            printWriter.println("Hello, World!"); // 写入一行字符流
            printWriter.println(42); // 写入一个整数
            printWriter.println(3.14); // 写入一个浮点数

            printWriter.flush();

            System.out.println("数据已成功写入到文件。");
        }
    }
}

